import request from '@/utils/request'
import { encryptionData } from '@/utils/com'
import Qs from 'qs'

// 代金券审核列表-分页
export function jcdCashCouponRecord(data) {
  return request({
    url: '/jcdGys/jcdCashCouponRecord/page',
    method: 'get',
    headers: encryptionData(data, '/jcdCashCouponRecord/page'),
    params: data
  })
}
// 代金券审核接口
export function jcdCashCouponRecordAudit(data) {
  return request({
    url: '/jcdGys/jcdCashCouponRecord/audit',
    method: 'post',
    headers: encryptionData(data, '/jcdCashCouponRecord/audit'),
    data: Qs.stringify(data)
  })
}
// 代金券保存或修改接口
export function saveOrUpdate(data) {
  return request({
    url: '/jcdGys/jcdCashCoupon/saveOrUpdate',
    method: 'post',
    headers: encryptionData(data, '/jcdCashCoupon/saveOrUpdate'),
    data: Qs.stringify(data)
  })
}
// 发放代金券选择指定会员时，获取会员数据接口
export function getStorePage(data) {
  return request({
    url: '/jcdGys/jcdCashCoupon/getStorePage',
    method: 'get',
    headers: encryptionData(data, '/cdCashCoupon/getStorePage'),
    params: data
  })
}
// 代金券分页查询接口
export function jcdCashCoupon(data) {
  return request({
    url: '/jcdGys/jcdCashCoupon/page',
    method: 'get',
    headers: encryptionData(data, '/jcdCashCoupon/page'),
    params: data
  })
}
// 发放代金券确认接口
export function provideCoupon(data) {
  return request({
    url: '/jcdGys/jcdCashCouponRecord/provideCoupon',
    method: 'post',
    headers: encryptionData(data, '/jcdCashCouponRecord/provideCoupon'),
    data: Qs.stringify(data)
  })
}

// 使代金券失效接口
export function setInvalid(data) {
  return request({
    url: '/jcdGys/jcdCashCoupon/setInvalid',
    method: 'post',
    headers: encryptionData(data, '/jcdCashCoupon/setInvalid'),
    data: Qs.stringify(data)
  })
}
// 代金券删除接口
export function delById(data) {
  return request({
    url: `/jcdGys/jcdCashCoupon/delById/${data.id}`,
    method: 'DELETE',
    headers: encryptionData(data, '/jcdCashCoupon/delById'),
  })
}
// 代金券详情接口
export function getById(data) {
  return request({
    url: `jcdGys/jcdCashCoupon/getById`,
    method: 'get',
    headers: encryptionData(data, '/jcdCashCoupon/getById'),
    params: data
  })
}
// 查看代金券接口
export function jcdCashCouponView(data) {
  return request({
    // url: `jcdGys/jcdCashCoupon/view`,
    url: `jcdGys/jcdCashCoupon/v2/view`,
    method: 'get',
    headers: encryptionData(data, '/jcdCashCoupon/v2/view'),
    params: data
  })
}
